package com.androidx.p013lv.mine.fragment;

import android.os.Bundle;
import android.view.View;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStoreOwner;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.listener.ItemClickListener;
import com.androidx.p013lv.base.utils.ToastUtils;
import com.androidx.p013lv.mine.adapter.VipCenterGoldAdapter;
import com.androidx.p013lv.mine.bean.VipCenterBean;
import com.androidx.p013lv.mine.databinding.VipCenterFragmentBinding;
import com.androidx.p013lv.mine.model.VipCenterModel;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/* renamed from: com.androidx.lv.mine.fragment.GoldCardFragment */
public class GoldCardFragment extends VipCenterFragment implements ItemClickListener {
    private VipCenterGoldAdapter goldAdapter;
    private List<VipCenterBean.GoldVipListBean> goldVipList;

    public static GoldCardFragment newInstance(int i) {
        Bundle bundle = new Bundle();
        bundle.putInt("data", i);
        GoldCardFragment goldCardFragment = new GoldCardFragment();
        goldCardFragment.setArguments(bundle);
        return goldCardFragment;
    }

    @Override // com.androidx.p013lv.mine.fragment.VipCenterFragment, com.androidx.p013lv.base.p015ui.LazyFragment
    public void initViews() {
        super.initViews();
        this.goldVipList = new ArrayList();
        VipCenterGoldAdapter vipCenterGoldAdapter = new VipCenterGoldAdapter();
        this.goldAdapter = vipCenterGoldAdapter;
        vipCenterGoldAdapter.setItemListener(this);
        ((VipCenterFragmentBinding) this.binding).recycler.setLayoutManager(new LinearLayoutManager(getContext(), 0, false));
        ((VipCenterFragmentBinding) this.binding).recycler.setAdapter(this.goldAdapter);
        ((VipCenterModel) new ViewModelProvider((ViewModelStoreOwner) Objects.requireNonNull(getActivity())).get(VipCenterModel.class)).dataVipCenter().observe((LifecycleOwner) Objects.requireNonNull(getActivity()), new Observer<BaseRes<VipCenterBean>>() {
            /* class com.androidx.p013lv.mine.fragment.GoldCardFragment.C13151 */

            public void onChanged(BaseRes<VipCenterBean> baseRes) {
                if (baseRes.getCode() == 200) {
                    GoldCardFragment.this.goldVipList = baseRes.getData().getGoldVipList();
                    GoldCardFragment.this.goldAdapter.setData(GoldCardFragment.this.goldVipList);
                    if (GoldCardFragment.this.goldVipList == null || GoldCardFragment.this.goldVipList.size() <= 0) {
                        GoldCardFragment.this.bean.setRechType(-1);
                        GoldCardFragment.this.bean.setMoney(0);
                        return;
                    }
                    GoldCardFragment.this.clickGoldCard(0);
                    return;
                }
                ToastUtils.getInstance().showSigh(baseRes.getMsg());
            }
        });
        ((VipCenterFragmentBinding) this.binding).llNewTime.setVisibility(8);
    }

    @Override // com.androidx.p013lv.base.listener.ItemClickListener
    public void onItemClick(View view, int i) {
        clickGoldCard(i);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void clickGoldCard(int i) {
        for (int i2 = 0; i2 < this.goldVipList.size(); i2++) {
            this.goldVipList.get(i2).setSelected(false);
        }
        this.goldVipList.get(i).setSelected(true);
        this.goldAdapter.setData(this.goldVipList);
        this.bean.setMoney(this.goldVipList.get(i).getPrice());
        this.bean.setPurType(3);
        this.bean.setGoldCardId(this.goldVipList.get(i).getGoldId());
        this.dialogMessage = this.goldVipList.get(i).getGoldNum() + "金幣";
        setVipType(this.goldVipList.get(i).getTypes());
        this.addGoldNum = this.goldVipList.get(i).getGoldNum() + this.goldVipList.get(i).getFreeGoldNum();
    }
}
